package io.tij;

import java.io.RandomAccessFile;
import java.nio.MappedByteBuffer;
import java.nio.channels.FileChannel;
import java.nio.channels.FileChannel.MapMode;

public class LargeMappedFiles {
	
	static int length = 0x8FFFFFF;

	public static void main(String[] args) throws Exception{
		FileChannel fileChannel = new RandomAccessFile("test.dat", "rw").getChannel();
		MappedByteBuffer buff = fileChannel.map(MapMode.READ_WRITE, 0, length);
		
		for(int i=0; i<length; i++){
			buff.put((byte)'x');
		}
		
		for(int i=length/2; i<length/2 + 6; i++){
			System.out.print((char) buff.get(i));
		}
	}

}
